#include<iostream>
using namespace std;
int find_number = 0;

int find_num(char *long_str,char *short_str);

int main()
{
   char long_str[10];
    char short_str[10];
    cout << "输入原始字符串：" << endl;
    cin >> long_str;
    cout << "输入查找字符串：" << endl;
    cin >> short_str;
    cout << "查找到的次数：" << find_num(long_str,short_str) << endl;


    return 0;
}

int find_num(char *long_str,char *short_str)
{
    if(short_str == NULL||long_str == NULL)
        return 0;
    
    char *l_begin = long_str;
    char *l_end = long_str;
    char *s_begin = short_str;
    char *s_end = short_str;


    while(*l_end != '\0')
        l_end++;
    while(*s_end != '\0')
        s_end++;
    //将最后一个\0符号往前挪一个
    //l_end--;
    while(l_begin < l_end)
    { 
        while(s_begin < s_end)
        {
            if(*l_begin == *s_begin)
                s_begin++;
            else
                {
                    l_begin++;
                    break;
                }
               
            if(*s_begin == *s_end)
                find_number++;
            l_begin++;
        }
        s_begin = short_str;

    }
    
    return find_number;
}